package com.cleaningcloud.erp.controller.mini;

import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.web.page.TableDataInfo;
import com.cleaningcloud.erp.api.domain.ErpCommodity;
import com.cleaningcloud.erp.domain.ErpCommodityType;
import com.cleaningcloud.erp.domain.vo.ErpCommodityVo;
import com.cleaningcloud.erp.service.IErpCommodityService;
import com.cleaningcloud.erp.service.IErpCommodityTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * packageName com.cleaningcloud.erp.controller.mini
 *
 * @author Shaw
 * @version JDK 8
 * @className MallCommodityController
 * @date 2025-04-02
 * @description 三才环科商城(小程序)商品接口
 */
@RestController
@RequestMapping("/mall/commodity")
public class MallCommodityController extends BaseController {

    @Autowired
    private IErpCommodityService commodityService;

    @Autowired
    private IErpCommodityTypeService commodityTypeService;

    /**
     * @Author Shaw
     * @Description 获取商品列表
     * @date: 2025-04-02 14:37
     * @param: //TODO
     */
    @GetMapping("/getCommodityList")
    public TableDataInfo list(ErpCommodity erpCommodity) {
        startPage();
        List<ErpCommodityVo> list = commodityService.selectMallCommodityList(erpCommodity);
        return getMiniDataTable(list);
    }

    /**
     * @Author Shaw
     * @Description 获取商品分类
     * @date: 2025-04-02 10:46
     * @param: //TODO
     */
    @GetMapping("/getCommodityTypeList")
    public AjaxResult getCommodityTypeList(ErpCommodityType erpCommodityType)
    {
        List<ErpCommodityType> list = commodityTypeService.selectMallErpCommodityTypeList(erpCommodityType);
        return success(list);
    }
}